import request from 'utils/request'
// 请求分类数据
const fetchCate = (params = {}) => request.get('/shop/goods/category/all', {
  params
})
// 请求首页轮播数据
const fetchBanner = (params = {}) => request.get('/banner/list', {
  params
})
// 请求商品列表
const fetchItem = (params = {}) => request.post('/shop/goods/list/v2', params)
// 商品详情
const fetchDetail = (id) => request.get('/shop/goods/detail', {
  params: {
    id
  }
})
// 用户登录
const doLogin = (params = {}) => request.post('/user/username/login', params)
// 用户注册
const register = (params = {}) => request.post('/user/username/register', params)
// 购物车请求数据
const fetchCartItems = (params = {}) => request.get('/shopping-cart/info', { params })
// 加入购物车
const addCart = (params = {}) => request.post('/shopping-cart/add', params)
// 修改购物车中的购买数量
const changeStepper = (params = {}) => request.post('/shopping-cart/modifyNumber', params)
// 修改商品选中状态
const switchCheck = (params = {}) => request.post('/shopping-cart/select', params)
// 删除商品
const delItem = (params = {}) => request.post('/shopping-cart/remove', params)
// 添加收货地址
const addContent = (params = {}) => request.get('/user/shipping-address/add', {
  params
})
// 获取联系人地址
const fetchContacts = (params = {}) => request.post('/user/shipping-address/list/v2',
  params
)
// 修改联系人信息
const UpdateContacts = (params = {}) => request.post('/user/shipping-address/update',
  params
)
// 获取联系人的个人详情
const getContent = (params = {}) => request.get('/user/shipping-address/detail/v2', {
  params
})

// 获取默认收货地址
const DefaultAddress = (params = {}) => request.get('/user/shipping-address/default/v2', {
  params
})

// 删除联系人信息
const DelContacts = (params = {}) => request.post('/user/shipping-address/delete',
  params
)
export {
  fetchCate,
  fetchBanner,
  fetchItem,
  fetchDetail,
  doLogin,
  register,
  fetchCartItems,
  addCart,
  changeStepper,
  switchCheck,
  delItem,
  addContent,
  fetchContacts,
  UpdateContacts,
  getContent,
  DelContacts,
  DefaultAddress
}
